﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

namespace SharedGenomics.Annotations
{
    [Serializable]
    public class NcbiAnnotation : IAnnotation
    {
        private IList<string> _geneNames;

        public NcbiAnnotation(string organism, string snpName, int? entrezGeneId, IEnumerable<string> geneNames, int? chromosome, long? chromosomalPosition)
        {
            this.OrganismName = organism;
            this.SnpName = snpName;
            this.EntrezGeneId = entrezGeneId;

            this._geneNames = new List<string>();

            if (geneNames != null)
            {
                foreach (string geneName in geneNames)
                    this._geneNames.Add(geneName);
            }

            this.Chromosome = chromosome;
            this.ChromosomalPosition = chromosomalPosition;
        }

        public string OrganismName { get; private set; }
        public string SnpName { get; private set; }
        public int? EntrezGeneId { get; private set; }

        public ICollection<string> GeneNames
        {
            get { return new ReadOnlyCollection<string>(this._geneNames); }
        }

        //WARNING: no validation is done on this field...this may need to be changed in future
        public int? Chromosome { get; private set; }

        //WARNING: no validation is done on this field...this may need to be changed in future
        public long? ChromosomalPosition { get; private set; }

        public AnnotationKey AnnotationKey
        {
            get { return AnnotationKey.NcbiSummary; }
        }

        public string EncodedKey
        {
            get
            {
                return "<annotation type=\"Ncbi\"><snp>" + System.Security.SecurityElement.Escape(SnpName) + "</snp></annotation>";
            }
        }

        public string Description
        {
            get
            {
                return "Ncbi Summary for " + SnpName;
            }
        }
    }
}